<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加用户</title>
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <link rel="stylesheet" href="../../css/iconfont.css">
    <link rel="stylesheet" href="../../css/base.css">
    <script src="../../js/jquery-1.11.0.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../js/frameAll.js"></script>
    <style>
        .layui-form {
            margin-top: 30px;
            margin-right: 50px;
        }
    </style>
    <script type="text/javascript">
        function getInfo() {
            return {
                username: $("input[name=username]").val(),
                pwd: $("input[name=password]").val(),
                comployeeNo: $("input[name=comployeeNo]").val(),
                competenceId: $("select[name=competenceId]").val(),
            };
        }

        function setInfo(username) {
            layui.use(['table', 'form'], function () {
                var form = layui.form;
                $.ajax({
                    type: "get",
                    url: "/fixedAsset/user/select.do",
                    data: {username: username},
                    dataType: "Json",
                    success: function (data) {
                        if (data.code === 0) {
                            var $username = $("input[name=username]");
                            $username.val(data.data.username);
                            $username.attr("readonly", '');
                            $username.css("border", 'none');
                            $("input[name=password]").attr("placeholder", "不输入默认为原密码");
                            $("input[name=comployeeNo]").val(data.data.comployeeNo);
                            $("select[name=competenceId]").val(data.data.competenceId);
                            form.render('select');
                        } else {
                            noMsg(data.message);
                        }
                    },
                    error: function () {
                        top.location.href = "../login.html";
                    }
                });
            });
        }

        layui.use(['table', 'form'], function () {
            var form = layui.form;
            //获取权限列表
            $.ajax({
                type: 'get',
                url: '/fixedAsset/user/competenceList.do',
                dataType: "Json",
                success: function (data) {
                    var $select = $('select[name=competenceId]');
                    for (let i = data.length - 1; i >= 0; i--) {
                        $select.append(new Option(data[i].competenceName, data[i].competenceId));
                    }
                    form.render('select');
                }
            });
        });
    </script>
</head>
<body>
<div class="cBody">
    <form class="layui-form" lay-filter="infoForm">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="username" autocomplete="off" class="layui-input"
                       placeholder="请输入用户名" lay-verify="name">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密&emsp;码 : </label>
            <div class="layui-input-inline shortInput">
                <input type="password" name="password" autocomplete="off" class="layui-input"
                       placeholder="不输入默认为用户名后六位" lay-verify="password">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">员工编号 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="comployeeNo" autocomplete="off" class="layui-input"
                       placeholder="请输入员工编号">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权&emsp;限 : </label>
            <div class="layui-input-inline shortInput">
                <select name="competenceId">
                </select>
            </div>
        </div>
    </form>
</div>
</body>
</html>